import 'package:flutter/material.dart';
import '../../manger/user_manger.dart';

class SecurityListItem extends StatelessWidget {
  final String title;
  final String description;
  final String actionText;
  final int indexs;

  const SecurityListItem({
    super.key,
    required this.title,
    required this.description,
    required this.actionText,
    required this.indexs,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left: 15, right: 15, top: 15),
      padding: const EdgeInsets.all(15),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12),
      ),
      child: Row(
        children: [
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: const TextStyle(
                    fontSize: 16,
                    color: Color(0xFF505050),
                  ),
                ),
                const SizedBox(height: 12),
                Text(
                  description,
                  style: const TextStyle(
                    fontSize: 13,
                    color: Color(0xFF666666),
                  ),
                ),
              ],
            ),
          ),
          Row(
            children: [
              Text(
                () {
                  if (indexs == 1) {
                    final emailValue = UserInfos.shared.userModel?.email?.email;
                    return (emailValue == null || emailValue.isEmpty) ? actionText : emailValue;
                  } else if (indexs == 2) {
                    final phoneValue = UserInfos.shared.userModel?.mobile?.mobile;
                    return (phoneValue == null || phoneValue.isEmpty) ? actionText : phoneValue;
                  } else {
                    return actionText;
                  }
                }(),
                style: const TextStyle(
                  fontSize: 13,
                  color: Color(0xFF5D5FEE),
                ),
              ),

              const SizedBox(width: 5),
              const Icon(
                Icons.chevron_right,
                size: 14,
                color: Color(0xFF5D5FEE),
              ),
            ],
          ),
        ],
      ),
    );
  }
}